package cn.lupin.controller;

import cn.lupin.utils.LaughJSONResult;
import cn.lupin.utils.RabbitMqSender;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {

    @Autowired
    private RabbitMqSender rabbitMqSender;

    @GetMapping("hello")
    public String hello() {
        return "hello";
    }

    @GetMapping("center")
    public String center() {
        return "center";
    }

    @ResponseBody
    @GetMapping("/send")
    public LaughJSONResult send(@Param("message") String message) {
        try {
            rabbitMqSender.sendMessage(message);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return LaughJSONResult.ok(message);
    }
}
